<template>
import { setTimeout } from 'timers';
  <div class="movie_body" ref="movie_body">
    <ul>
      <li>{{pullDownMsg}}</li>
      <li v-for="item in movieList" :key="item.id">
        <div class="pic_show" @tap="handleToDetail"><img :src="item.img | setWH('128.180')"></div>
        <div class="info_list">
          <!--img的setWH函数写的有问题-->
          <h2>{{item.nm}}<img></h2>
          <p>观众评分<span class="grade" >{{item.sc}}</span></p>
          <p>主演：{{item.star}}</p>
          <p>{{item.showInfo}}</p>
        </div>
        <div class="btn_mall">
          购票
        </div>
      </li>
    </ul>
  </div>
</template>

import BScroll from 'better-scroll';






<script>
export default {
  name:'NowPlaying',
  data(){
    return{
      movieList:[],
      pullDownMsg:''
    }
  },
  mounted() {
    //先选择上海id=10
    this.axios.get('/api/movieOnInfoList?cityId=10').then((res)=>{
      var msg = res.data.msg;
      if(msg === 'ok'){
        this.movieList = res.data.data.movieList;
        this.$nextTick(()=>{
          new BScroll(this.$refs.movie_body,{
            tap:true,
            probeType:1
          });
          });
          scroll.on('scroll',(pos)=>{
            //console.log('滑动时');
            if(pos.y>30){
              this.pullDownMsg = "正在刷新中";
            }
          });
          scroll.on('touchEnd',(pos)=>{
            //console.log('停下时);
            if(pos.y>30){
              this.axios.get('/api/movieOnInfoList?cityId=10').then((res)=>{
              var msg = res.data.msg;
              if(msg === 'ok'){
                this.pullDownMsg = "更新成功";
                setTimeout(()=>{
                  this.movieList = res.data.data.movieList;
                  this.pullDownMsg='';
                },1000);
              }
          });
        }
      });
      }
  },
  methods:{
    handleToDetail(){
      
    }
  }
}
</script>

<style scoped>
  #content .movie_body{
    flex:1;
    overflow: auto;
  }
  .movie_body ul{
    margin: 0 12px;
    overflow: hidden;
  }
  .movie_body ul li{
    margin-top: 12px;
    display: flex;
    align-items: center;
    border-bottom: 1px #e6e6e6 solid;
    padding-bottom: 10px;
  }
  .movie_body pic_show{
    width: 64px;
    height: 90px;
  }
  .movie_body pic_show img{
    width: 25px;
  }
  .movie_body .info_list{
    margin-left: 10px;
    flex: 1;
    position: relative;
  }
  .movie_body .info_list h2{
    font-size: 20px;
    line-height: 22px;
    width: 200px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }
  .movie_body .info_list p{
    font-size: 16px;
    color: #666;
    line-height: 22px;
    width: 200px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }
  .movie_body .info_list .grade{
    font-weight: 700;
    color: #faaf00;
    font-size: 15px;
  }
  .movie_body .info_list img{
    width: 50px;
    position: absolute;
    right: 10px;
    top: 5px;
  }
  .moive_body .btn_mall, .movie_body .btn_pre{
    width:47px;
    height: 27px;
    line-height: 28px;
    text-align: center;
    background-color:#f03d37;
    color:#fff;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
  }
  .moive_body .btn_pre{
    background-color: #3c9fe6;
  }
  .moive_body .pullDown{
    margin: 0;
    padding: 0;
    border: none;
  }
</style>
